// GTY


#include "AbilitySystem/ModMagCalc/MMC_MaxHealth.h"

#include "AbilitySystem/AuraAttributeSet.h"
#include "Interaction/CombatInterface.h"

UMMC_MaxHealth::UMMC_MaxHealth()
{
	VigorDef.AttributeToCapture = UAuraAttributeSet::GetVigorAttribute();
	VigorDef.AttributeSource = EGameplayEffectAttributeCaptureSource::Target;//效果设置成目标（源，目标）
	VigorDef.bSnapshot = false;//不需要快照

	RelevantAttributesToCapture.Add(VigorDef);//添加要捕获的属性
}

float UMMC_MaxHealth::CalculateBaseMagnitude_Implementation(const FGameplayEffectSpec& Spec) const
{
	//从源和目标收集标记
	const FGameplayTagContainer * SourceTags = Spec.CapturedSourceTags.GetAggregatedTags();//源标签
	const FGameplayTagContainer * TargetTags = Spec.CapturedTargetTags.GetAggregatedTags();//目标标签

	FAggregatorEvaluateParameters EvaluationParameters;//评估参数
	EvaluationParameters.SourceTags = SourceTags;
	EvaluationParameters.TargetTags = TargetTags;

	float Vigor = 0.f;
	/*传入四个参数：属性定义（VigorDef）、规格（Spec）、评估参数（EvaluationParameters）和输出变量（Vigor）。
		函数根据传入的参数计算并返回捕获属性的值，最终赋值给Vigor。*/
	GetCapturedAttributeMagnitude(VigorDef, Spec, EvaluationParameters, Vigor);
	Vigor = FMath::Max<float>(Vigor, 0.f);

	//获取角色的等级
	int32 PlayerLevel = 1;
	if (Spec.GetContext().GetSourceObject()->Implements<UCombatInterface>())
	{
		PlayerLevel = ICombatInterface::Execute_GetPlayerLevel(Spec.GetContext().GetSourceObject());
	}
	
	
	return 80.f + 2.5f * Vigor + 10.f * PlayerLevel;
	
}
